@push('article_social_share')
<style>
    .nav-list li.active{background:#EEEEEE}
</style>

<script>

    $(document).ready(function()
    {
        var $config = {
            title               : document.title + ' | from DS #dspstack.com# {{ $topic->user->id != 1 ? '@AllenZhangFive' : '' }} {{ $topic->user->weibo_name ? '@'.$topic->user->weibo_name : '' }}',
            wechatQrcodeTitle   : "微信扫一扫：分享", // 微信二维码提示文字
            wechatQrcodeHelper  : '<p>微信里点“发现”，扫一下</p><p>二维码便可将本文分享至朋友圈。</p>',
            image               : "{{ $cover ? $cover->link : $blog->cover }}",
            sites               : ['weibo','wechat',  'facebook', 'twitter', 'google','qzone', 'qq', 'douban'],
        };

        socialShare('.social-share-cs', $config);

        Config.following_users =  @if($currentUser) {!!$currentUser->present()->followingUsersJson()!!} @else [] @endif;
        PHPHub.initAutocompleteAtUser();
    });


    $(document).ready(function () {
        let width = $("#toc-card").outerWidth();
        $("#toc-card").css('width', width);
        $(window).resize(function(){
            $("#toc-card").css('width', 'auto');
            let width = $(".card").outerWidth();
            $("#toc-card").css('width', width);
        });

        var toc = $("#toc").tocify({
            context:$('.content-body'),
            selectors: "h2,h3,h4",
            showAndHide:true,
            showEffect:"fadeIn",
            extendPage:false,
            highlightDefault:true
        }).data("toc-tocify");

        prettyPrint();
        $(".optionName").popover({
            trigger: "hover"
        });

        var topX = $(".card").offset().top;
            $(window).scroll(function()
            {
                if($(window).scrollTop() >= topX)
                {
                    $("#toc-card").addClass('flex');
                }
                else
                {
                    $("#toc-card").removeClass('flex');
                }
            });

    });

</script>

@endpush

@extends('layouts.default')

@section('title')
{{ $topic->title }} | @parent
@stop

@section('wechat_icon')
<img src="{{ img_crop($blog->cover, 512, 512) }}" alt="">
@stop

@section('content')

<div class="blog-pages">

          <div class="col-md-9 left-col pull-right">

              <div class="panel article-body content-body">
                  
                  <div class="panel-body">

                        <h1 class="text-center">
                            {{ $topic->title }}
                        </h1>

                        @if ($topic->is_draft == 'yes')
                            <div class="text-center alert alert-warning">
                                当前状态为 <i class="fa fa-file-text-o"></i> 草稿，仅作者可见，请前往 <a href="{{ route('articles.edit', $topic->id) }}" class="no-pjax">编辑发布</a>
                            </div>
                        @endif

                        <div class="article-meta text-center">

                            创建于 <abbr title="{{ $topic->created_at }}" class="timeago">{{ $topic->created_at }}</abbr>
                            <span class="divider">/</span>
                            阅读数 {{ number_shorten($topic->view_count) }}
                            <span class="divider">/</span>
                            点赞数 {{ number_shorten($topic->vote_count) }}
                            <span class="divider">/</span>
                            评论数 {{ number_shorten($topic->reply_count) }}

                        </div>

                        <div class="entry-content">
                            @include('topics.partials.body', array('body' => $topic->body))
                        </div>


                        {{--<div class="post-info-panel">--}}
                            {{--<p class="info">--}}
                                {{--<label class="info-title">版权声明：</label><i class="fa fa-fw fa-creative-commons"></i>自由转载-非商用-非衍生-保持署名（<a href="https://creativecommons.org/licenses/by-nc-nd/3.0/deed.zh">创意共享3.0许可证</a>）--}}
                            {{--</p>--}}
                        {{--</div>--}}
                        <br>
                        <div class="meta">
                          <i class="icon fa fa-tags"></i>
                          @foreach($topic->tags as $tag)
                              <a class="ui topic-label" href="{{ route('tags.show', ['id' => $tag->id]) }}" target="_blank">{{ $tag->name }}</a>
                          @endforeach
                      </div>
                        <br>
                        @include('topics.partials.topic_operate', ['is_article' => true, 'manage_topics' => $currentUser ? ($currentUser->can("manage_topics") && $currentUser->roles->count() <= 5) : false])
                  </div>

              </div>

              @include('topics.partials.show_segment')
        </div>

        @if( $topic->user->payment_qrcode )
            @include('topics.partials.payment_qrcode_modal')
        @endif

        <div class="col-md-3 main-col pull-left">
            @include('blogs._info')
            @include('blogs._archive')
            


            @if (count($userTopics))

            <!-- <div class="recommended-wrap"> -->
                <div class="panel panel-default corner-radius recommended-articles">
                    <div class="panel-heading text-center">
                      <h3 class="panel-title">博客推荐</h3>
                    </div>
                    <div class="panel-body">
                      @include('layouts.partials.sidebar_topics', ['sidebarTopics' => $userTopics, 'is_article' => true])
                    </div>
                </div>
            <!-- </div> -->

            @endif

                <div class="card" id="toc-card">
                    <div id="toc" style="background-color: #fff;" >
                    </div>
                </div>
        </div>

</div>
<div class="clearfix"></div>
@stop
